From c2ba001caf5125412bb82325f8a21f3eacf17958 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 28 Jan 2015 16:32:01 +0100 Subject: [PATCH] kexec: prefer __copy_to_guest() when possible It's slightly cheaper and safe as long a copy_from_guest() for the same guest address range was issued before. Signed-off-by: Jan Beulich Acked-by: David Vrabel --- xen/common/kexec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/common/kexec.c b/xen/common/kexec.c index 05d5de7a75..3b4275e736 100644 --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -662,8 +662,8 @@ static int kexec_get_range(XEN_GUEST_HANDLE_PARAM(void) uarg) ret = kexec_get_range_internal(&range); - if ( ret == 0 && unlikely(copy_to_guest(uarg, &range, 1)) ) - return -EFAULT; + if ( ret == 0 && unlikely(__copy_to_guest(uarg, &range, 1)) ) + ret = -EFAULT; return ret; } @@ -686,10 +686,11 @@ static int kexec_get_range_compat(XEN_GUEST_HANDLE_PARAM(void) uarg) if ( (range.start | range.size) & ~(unsigned long)(~0u) ) return -ERANGE; - if ( ret == 0 ) { + if ( ret == 0 ) + { XLAT_kexec_range(&compat_range, &range); - if ( unlikely(copy_to_guest(uarg, &compat_range, 1)) ) - return -EFAULT; + if ( unlikely(__copy_to_guest(uarg, &compat_range, 1)) ) + ret = -EFAULT; } return ret; -- 2.30.2